<template>
  <el-col class="info-wrapper" :span="23">
    <el-form
      ref="form"
      :model="searchParams"
      class="search-from main-content"
      label-width="120px"
    >
      <el-col class="search-col">
        <el-form-item label="生产企业" prop="productionCompany">
          <el-input v-model="searchParams.productionCompany"></el-input>
        </el-form-item>
        <el-form-item label="检查类型" prop="testType">
          <el-select
            v-model="searchParams.testType"
            placeholder="请选择"
          >
            <el-option
              v-for="item in testTypeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col class="search-col">
        <el-form-item label="检测任务号" prop="testTaskId">
          <el-input v-model="searchParams.testTaskId"></el-input>
        </el-form-item>
        <el-form-item label="计划时间" prop="planStartTime">
          <el-date-picker
            v-model="searchParams.planStartTime"
            type="date"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="至" prop="planEndTime">
          <el-date-picker
            v-model="searchParams.planEndTime"
            type="date"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="工厂编号" prop="companyId">
          <el-input v-model="searchParams.companyId"></el-input>
        </el-form-item>
      </el-col>
      <el-col class="search-col operation-area">
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">清空</el-button>
        <el-button @click="batchExport">批量导出</el-button>
      </el-col>
    </el-form>

    <el-tabs class="table-tabs" type="border-card">
      <el-tab-pane>
        <span slot="label">未完成 {{undoneTableData.length}}</span>
        <el-table border :data="undoneTableData">
          <el-table-column prop="date" label="检查任务号"> </el-table-column>
          <el-table-column prop="date" label="生产企业"> </el-table-column>
          <el-table-column prop="date" label="分公司"> </el-table-column>
          <el-table-column prop="date" label="检查类型"> </el-table-column>
          <el-table-column prop="date" label="审厂类型"> </el-table-column>
          <el-table-column prop="date" label="组内身份"> </el-table-column>
          <el-table-column prop="date" label="计划开始时间"> </el-table-column>
          <el-table-column prop="date" label="计划结束时间"> </el-table-column>
          <el-table-column prop="operation" label="操作">
            <el-link type="primary" @click="toDetail">详情</el-link>
          </el-table-column>
        </el-table>
      </el-tab-pane>

      <el-tab-pane>
        <span slot="label">已完成 {{finishTableData.length}}</span>
        <el-table border :data="finishTableData">
          <el-table-column prop="date" label="检查任务号"> </el-table-column>
          <el-table-column prop="date" label="生产企业"> </el-table-column>
          <el-table-column prop="date" label="分公司"> </el-table-column>
          <el-table-column prop="date" label="检查类型"> </el-table-column>
          <el-table-column prop="date" label="审厂类型"> </el-table-column>
          <el-table-column prop="date" label="组内身份"> </el-table-column>
          <el-table-column prop="date" label="计划开始时间"> </el-table-column>
          <el-table-column prop="date" label="计划结束时间"> </el-table-column>
          <el-table-column prop="operation" label="操作">
            <el-link type="primary" @click="toDetail">详情</el-link>
          </el-table-column>        
        </el-table>
      </el-tab-pane>

      <el-tab-pane>
        <span slot="label">资料复核退回 {{returnTableData.length}}</span>
        <el-table border :data="returnTableData">
          <el-table-column prop="date" label="检查任务号"> </el-table-column>
          <el-table-column prop="date" label="生产企业"> </el-table-column>
          <el-table-column prop="date" label="分公司"> </el-table-column>
          <el-table-column prop="date" label="检查类型"> </el-table-column>
          <el-table-column prop="date" label="审厂类型"> </el-table-column>
          <el-table-column prop="date" label="组内身份"> </el-table-column>
          <el-table-column prop="date" label="计划开始时间"> </el-table-column>
          <el-table-column prop="date" label="计划结束时间"> </el-table-column>
          <el-table-column prop="operation" label="操作">
            <el-link type="primary" @click="toDetail">详情</el-link>
          </el-table-column>        
        </el-table>
      </el-tab-pane>
    </el-tabs>
  </el-col>
</template>

<script>
export default {
  name: 'productReview',
  data() {
    return {
      defulatParams: {
        productionCompany: "", // 生产企业
        companyId: "", // 工厂编号
        testTaskId: "", // 检测任务号
        testType: "", // 检查类型
        planStartTime: "", // 计划时间
        planEndTime: "", // 至（计划时间）
      },
      searchParams: {
        ...this.defulatParams,
      },
      undoneTableData: [{date: 123}], // 未完成表格数据
      finishTableData: [], // 已完成表格数据
      returnTableData: [], // 退回表格数据
      testTypeList: [], // 检查类型列表
    };
  },
  mounted() {
    this.queryTableData();
  },
  methods: {
    search() {
      // todo: 搜索方法
    },
    reset() {
      this.searchParams = {
        ...this.defulatParams,
      };
      this.search();
    },
    batchExport() {
      // todo: 批量导出方法
    },
    queryTableData() {
      // todo：获取表格数据接口
    },
    toDetail(row) {
      this.$router.push({
        path: "/product/mine/task/detail",
        query: row
      });
    }
  },
};
</script>

<style lang="less" scoped>
.info-wrapper {
  font-family: Source Han Sans CN;
  font-weight: 400;
  height: 100%;

  .search-from {
    display: flex;
    flex-wrap: wrap;
    border: 1px solid #c2d9e6;
    padding-top: 20px;

    .search-col {
      display: flex;
    }

    .operation-area {
      margin-left: 20px;
      margin-bottom: 10px;
    }
  }

  .table-tabs {
    margin-top: 15px;
  }
}
</style>
